<!DOCTYPE html>
<html lang="ru">
{% load static %}
{% load ann_notifications %}

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="{% static 'img/global/icon.png' %}">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
    <link rel="stylesheet" href="{% static 'css/global/footer.css' %}?v=1">
    <link rel="stylesheet" href="{% static 'css/global/index.css' %}?v=3">
    <link rel="stylesheet" href="{% static 'css/home_page/home.css' %}?v=4">
    <link rel="stylesheet" href="{% static 'css/media/home_page/home.css' %}?v=1">
    <link rel="stylesheet" href="{% static 'css/dec/dec.css' %}?v=3">
    <link rel="stylesheet" href="{% static 'css/global/list.css'%}?v=2">
    <title>Объявления</title>
</head>

<body>
    <header class="header">
        <a href="{% url 'home' %}" class="logo"><img src="{% static 'img/global/long_logo.svg' %}"
                alt="Логотип лицея"></a>
        <nav class="nav">
            <ul class="nav-list">
                <li class="nav-item">
                    <a href="{% url 'home' %}#contests">Конкурсы</a>
                </li>
                <li class="nav-item">
                    <a href="{% url 'announcements' %}">Объявления</a>
                </li>
                <li class="nav-item">
                    <a href="{% url 'documents' %}">Норм. документы</a>
                </li>
            </ul>
        </nav>
        {% if user.is_authenticated %}
        <div class="user">
            <button class="user-avatar" onclick="user(this)">
                <img class="avatar" src="{{ user.avatar.url }}" alt="Аватарка пользователя">
                <div class="user-arrow-down">
                    <svg height="512px" id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1"
                        viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
                        xmlns:xlink="http://www.w3.org/1999/xlink" fill="#000000">
                        <polygon points="160,115.4 180.7,96 352,256 180.7,416 160,396.7 310.5,256 " />
                    </svg>
                </div>
            </button>
            <div class="user-content">
                <a class="user-info" href="{% url 'profile' %}">
                    <img class="avatar" src="{{ user.avatar.url }}" alt="Аватарка пользователя">
                    <div class="user-naming">
                        <h2 class="user-fio">{{user.getPName}}</h2>
                        <p class="user-username logedin">{{user.username}}</p>
                        <div class="user-arrow">
                            <svg height="512px" id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1"
                                viewBox="0 0 512 512" width="512px" xml:space="preserve"
                                xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
                                fill="rgb(31 63 118 / 51%)">
                                <polygon points="160,115.4 180.7,96 352,256 180.7,416 160,396.7 310.5,256 " />
                            </svg>
                        </div>
                    </div>
                </a>
                <ul class="user-links-list">
                    <li class="user-links-item">
                        <a href="{% url 'theme_list' %}" class="user-link theme-icon">Список тем</a>
                    </li>
                    <li class="user-links-item">
                        <a href="{% url 'projects' %}" class="user-link project-icon">Управление проектом</a>
                    </li>
                    <li class="user-links-item">
                        <a href="{% url 'archive' %}" class="user-link archive-icon">Архив работ</a>
                    </li>
                    {% if user.is_superuser %}
                    <li class="user-links-item">
                        <a href="{% url 'admin_menu' %}" class="user-link">Администрирование</a>
                    </li>
                    {% endif %}
                </ul>
                <form action="{% url 'logout' %}" method="post">
                    {% csrf_token %}
                    <button class="user-button" type="submit">Выйти из профиля</button>
                </form>
            </div>
        </div>
        {% else %}
        <a class="user" href="{% url 'login' %}">
            <p class="username">Войти</p>
        </a>
        {% endif %}

    </header>
    <main class="main">
        
    <div class="main-nav">
        <form method="GET" action="{% url 'search' %}" class="filter-form">
            {% csrf_token %}
            <div class="main-nav-top">
                <input class="search-input" type="text" placeholder="Поиск по объявлениям" value="{{ search_value }}" name="q">
                <button class="search-button">
                    <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <path
                            d="M17.6339 15.8664L14.4607 12.6932C15.1164 11.7051 15.5001 10.522 15.5001 9.25006C15.5001 5.80378 12.6964 3 9.25006 3C5.80378 3 3 5.80378 3 9.25006C3 12.6964 5.80378 15.5001 9.25006 15.5001C10.522 15.5001 11.7051 15.1164 12.6932 14.4607L15.8664 17.6339C16.3539 18.122 17.1464 18.122 17.6339 17.6339C18.122 17.1458 18.122 16.3545 17.6339 15.8664ZM4.87502 9.25006C4.87502 6.83754 6.83754 4.87502 9.25006 4.87502C11.6626 4.87502 13.6251 6.83754 13.6251 9.25006C13.6251 11.6626 11.6626 13.6251 9.25006 13.6251C6.83754 13.6251 4.87502 11.6626 4.87502 9.25006Z"
                            fill="#5a88ff" />
                    </svg>
                </button>
            </div>
        </form>
        {% if user.role == 'Администратор' or user.role == 'Учитель' %}
            <a href="{% url 'redactor' %}" class="create-link">
                <span>Создать объявление</span>
                <svg width="20" height="20" viewBox="0 0 200 200" style="transform: rotate(45deg)">
                    <path d="m114 100 49-49a9.9 9.9 0 0 0-14-14l-49 49-49-49a9.9 9.9 0 0 0-14 14l49 49-49 49a9.9 9.9 0 0 0 14 14l49-49 49 49a9.9 9.9 0 0 0 14-14Z" fill="#FFFFFF"></path>
                </svg>
          </a>
        {% endif %}
    </div>

    <div class="content" id="FSL"> <!-- FSL==Facking Scroll List-->
        {% for announcement in page_announcements %}
        <div class="announ">
            <div class="announ-content" id="{{ announcement.id }}">
                <div class="top-info">
                    <div class="top-info-text">
                        {% if announcement.date_of_expiring %}
                            {% if announcement.updated_at == announcement.created_at %}
                            <span class="date">c <span class="date-start">{{ announcement.created_at }}</span> до <span class="date-end">{{ announcement.date_of_expiring }}</span></span>
                            {% else %}
                            <span class="change">изм.</span>
                            <span class="date">c <span class="date-start">{{ announcement.updated_at }}</span> до <span class="date-end">{{ announcement.date_of_expiring }}</span></span>
                            {% endif %}
                        {% else %}    
                            {% if announcement.updated_at == announcement.created_at %}
                            <span class="date">{{ announcement.created_at }}</span>
                            {% else %}
                            <span class="change">изм.</span>
                            <span class="date">{{ announcement.updated_at }}</span>
                            {% endif %}
                        {% endif %}
                    </div>
                    <div style="display: flex; column-gap: 15px;">
                        <button class="favourite-btn" title="Закрепить">
                            {% if announcement.is_pinned %}
                            <svg class="favourite-svg" width="18" height="18" viewBox="0 0 18 18" fill="#E4CE02">
                                <path d="M17.6844 6.825C17.615 6.61154 17.4877 6.4215 17.3168 6.27597C17.1459 6.13045 16.9381 6.03514 16.7163 6.00063L12.1481 5.31625L10.0919 0.95125C9.8875 0.51875 9.46938 0.25 9 0.25C8.53063 0.25 8.1125 0.51875 7.90813 0.95125L5.88188 5.30063L1.28375 6.00063C0.833755 6.06938 0.46313 6.385 0.31563 6.825C0.241171 7.04419 0.228913 7.27972 0.280215 7.50545C0.331518 7.73118 0.444374 7.93828 0.606255 8.10375L3.93188 11.5075L3.14625 16.305C3.10629 16.5361 3.1327 16.7739 3.22242 16.9906C3.31214 17.2073 3.46149 17.3941 3.65313 17.5294C3.83519 17.6597 4.05052 17.7355 4.27404 17.7482C4.49756 17.7608 4.72007 17.7096 4.91563 17.6006L8.97125 15.3356L13.0844 17.6006C13.28 17.7094 13.5025 17.7604 13.7259 17.7478C13.9494 17.7352 14.1647 17.6595 14.3469 17.5294C14.5386 17.3942 14.6881 17.2074 14.7778 16.9907C14.8675 16.7739 14.8939 16.5361 14.8538 16.305L14.0669 11.5013L17.3938 8.10375C17.5556 7.93828 17.6685 7.73118 17.7198 7.50545C17.7711 7.27972 17.7588 7.04419 17.6844 6.825Z" fill="inherit"/>
                            </svg>
                            {% else %}
                            <svg class="favourite-svg" width="18" height="18" viewBox="0 0 18 18" fill="inherit">
                                <path d="M17.6844 6.825C17.615 6.61154 17.4877 6.4215 17.3168 6.27597C17.1459 6.13045 16.9381 6.03514 16.7163 6.00063L12.1481 5.31625L10.0919 0.95125C9.8875 0.51875 9.46938 0.25 9 0.25C8.53063 0.25 8.1125 0.51875 7.90813 0.95125L5.88188 5.30063L1.28375 6.00063C0.833755 6.06938 0.46313 6.385 0.31563 6.825C0.241171 7.04419 0.228913 7.27972 0.280215 7.50545C0.331518 7.73118 0.444374 7.93828 0.606255 8.10375L3.93188 11.5075L3.14625 16.305C3.10629 16.5361 3.1327 16.7739 3.22242 16.9906C3.31214 17.2073 3.46149 17.3941 3.65313 17.5294C3.83519 17.6597 4.05052 17.7355 4.27404 17.7482C4.49756 17.7608 4.72007 17.7096 4.91563 17.6006L8.97125 15.3356L13.0844 17.6006C13.28 17.7094 13.5025 17.7604 13.7259 17.7478C13.9494 17.7352 14.1647 17.6595 14.3469 17.5294C14.5386 17.3942 14.6881 17.2074 14.7778 16.9907C14.8675 16.7739 14.8939 16.5361 14.8538 16.305L14.0669 11.5013L17.3938 8.10375C17.5556 7.93828 17.6685 7.73118 17.7198 7.50545C17.7711 7.27972 17.7588 7.04419 17.6844 6.825Z" fill="inherit"/>
                            </svg>
                            {% endif %}
                        </button>
    
                        {% if announcement.author_id == user.id or user.role == 'Администратор' %}
                        <button class="announ-delete-btn" onclick="del_open(`{% url 'delete' announcement.id %}`)">
                            <svg viewBox="0 0 200 200" width="20px" height="20px"><path d="m114 100 49-49a9.9 9.9 0 0 0-14-14l-49 49-49-49a9.9 9.9 0 0 0-14 14l49 49-49 49a9.9 9.9 0 0 0 14 14l49-49 49 49a9.9 9.9 0 0 0 14-14Z" fill="#f05454"></path></svg>
                        </button>
                        {% endif %}
                    </div>

                </div>
                <div class="middle-info">
                    <h2 class="announ-title">{{ announcement.title }}</h2>
                    {% if announcement.author_id == user.id or user.role == 'Администратор' %}
                    <a href="{% url 'redactor' %}/{{ announcement.id }}">
                        <svg height="20px" version="1.1" viewBox="0 0 18 18" width="20px">
                            <g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1">
                                <g fill="#4472e9" transform="translate(-213.000000, -129.000000)">
                                    <g transform="translate(213.000000, 129.000000)">
                                        <path
                                            d="M0,14.2 L0,18 L3.8,18 L14.8,6.9 L11,3.1 L0,14.2 L0,14.2 Z M17.7,4 C18.1,3.6 18.1,3 17.7,2.6 L15.4,0.3 C15,-0.1 14.4,-0.1 14,0.3 L12.2,2.1 L16,5.9 L17.7,4 L17.7,4 Z"
                                            id="Shape" />
                                    </g>
                                </g>
                            </g>
                        </svg>
                    </a>
                    {% endif %}
                </div>
                <div class="announ-descr">
                    {{ announcement.body|safe }}
                </div>
                <button class="announ-btn">Подробнее</button>
                <div class="announ-bottom">
                    <div>
                        <a href="#" class="announ-author">{{ announcement.author }}</a>
                    </div>
                    {% load filters %}
                    <ul class="announ-files-list">
                        {% for file in announcement.files.all %}
                        <li class="announ-files-item">
                            <a href="{{ file.file.url }}" class="announ-files-link">{{ file.file.url|split|encode }}</a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
             <div class="announ-img" style="background-image: {{ announcement.image_url }}"></div>
        </div>
        {% endfor %}
    </div>
    <div class="back-form"></div>

<button id="load-more-button" class="load-btn">Загрузить ещё</button>

<div class="delete-div">
    <p class="delete-title">Вы уверены, что хотите удалить объявление?</p>
    <div class="delete-btns">
        <button class="delete-btn" type="button" onclick="del_exit()">Отмена</button>
        <a href="#" class="delete-btn delete-btn-link">Удалить</a>
    </div>
</div>

<script>
        let totalAnnouncements = {{ count }};
        let searchValue = '{{ search_value }}';
</script>
<script src="{% static 'js/announcement/dec.js' %}"></script>
    </main>


    <footer class="footer">
        <div class="container">
            <div class="footer-top">
                <a href="{% url 'home' %}" class="long-logo"><img src="{% static 'img/global/long_logo_white.svg' %}"
                        alt="Логотип лицея"></a>
                <address class="footer-contact">
                    <p class="footer-title">Контакты</p>
                    <div>
                        <ul class="footer-contact-list">
                            <li class="footer-contact-item">
                                <a href="https://yandex.ru/maps/org/maou_litsey_38/1018549864/?indoorLevel=1&ll=44.015949%2C56.315411&z=17.09" target="_blank">Нижний Новгород, ул. Ванеева, 7/57</a>
                            </li>
                            <li class="footer-contact-item">
                                <a href="mailto:l38_nn@mail.52gov.ru">l38_nn@mail.52gov.ru</a>
                            </li>
                            <li class="footer-contact-item">
                                <a href="tel:+78314288306">+ 7(831) 428-83-06</a>
                            </li>
                        </ul>
                    </div>
                </address>
                <div class="useful-links">
                    <p class="footer-title">Полезные ссылки</p>
                    <div class="footer-useful-links">
                        <a class="lic-link" href="https://ntl38.ru" target="_blank">Официальный сайт лицея</a>
                        <a class="lic-link" href="https://t.me/+F-Ck6-C7jPEwYzAy" target="_blank">Сообщить об ошибке</a>
                    </div>
                </div>
                <div class="footer-links">
                    <p class="footer-title">Мы в соц. сетях</p>
                    <a href="https://vk.com/lycee38ntl">
                        <svg width="25" height="25" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <g clip-path="url(#clip0_427_18)">
                                <path
                                    d="M19.2152 4.49854H15.9698C15.8373 4.49854 15.7073 4.53445 15.5936 4.60246C15.4799 4.67047 15.3868 4.76802 15.3242 4.88475C15.3242 4.88475 14.0298 7.26862 13.6139 8.0716C12.4954 10.2315 11.771 9.55344 11.771 8.55096V5.09445C11.771 4.80561 11.6563 4.5286 11.4521 4.32436C11.2478 4.12012 10.9708 4.00538 10.682 4.00538H8.24184C7.90952 3.98067 7.57641 4.04133 7.27414 4.18159C6.97186 4.32185 6.71046 4.53705 6.51478 4.80677C6.51478 4.80677 7.75386 4.60643 7.75386 6.27598C7.75386 6.68998 7.77518 7.88096 7.79461 8.87984C7.79827 9.02712 7.75668 9.17184 7.67545 9.29464C7.59422 9.41752 7.47726 9.5124 7.34036 9.56664C7.20346 9.62088 7.05322 9.63184 6.90992 9.59792C6.76662 9.56408 6.63716 9.48704 6.53902 9.37728C5.54022 7.98813 4.71288 6.48342 4.07498 4.89583C4.0202 4.77707 3.9325 4.67652 3.82229 4.6061C3.71207 4.53568 3.58398 4.49835 3.45319 4.49854C2.74935 4.49854 1.3409 4.49854 0.504462 4.49854C0.423354 4.49799 0.343322 4.51713 0.271246 4.55434C0.199169 4.59154 0.137201 4.64569 0.0906656 4.71212C0.0441302 4.77855 0.0144189 4.85529 0.004084 4.93574C-0.00625087 5.01619 0.00309974 5.09795 0.0313325 5.17399C0.926712 7.63 4.7837 15.3482 9.18608 15.3482H11.039C11.2332 15.3481 11.4194 15.271 11.5566 15.1337C11.6939 14.9964 11.771 14.8102 11.771 14.6161V13.4972C11.771 13.3569 11.8122 13.2195 11.8892 13.1022C11.9662 12.985 12.076 12.8927 12.2048 12.837C12.3336 12.7813 12.4759 12.7645 12.6142 12.7886C12.7525 12.8128 12.8806 12.8769 12.983 12.973L15.2008 15.0568C15.4 15.2439 15.663 15.3481 15.9363 15.3482H18.8487C20.2534 15.3482 20.2534 14.3734 19.4876 13.6191C18.9486 13.0883 17.0037 11.0383 17.0037 11.0383C16.8371 10.8658 16.7378 10.6394 16.7236 10.3999C16.7094 10.1606 16.7814 9.924 16.9264 9.73296C17.555 8.90568 18.5833 7.55146 19.0194 6.97133C19.6154 6.17838 20.6942 4.49854 19.2152 4.49854Z"
                                    fill="white" />
                            </g>
                        </svg>
                    </a>
                    <a href="https://t.me/ntl_38">
                        <svg width="25" height="25" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path
                                d="M19.9419 3.85158L16.9241 16.3047C16.6964 17.1836 16.1027 17.4024 15.2589 16.9883L10.6608 14.0234L8.44195 15.8906C8.19643 16.1055 7.99107 16.2852 7.51786 16.2852L7.84822 12.1875L16.3705 5.44924C16.7411 5.16018 16.2902 5.00002 15.7947 5.28909L5.25893 11.0938L0.723217 9.8516C-0.26339 9.58208 -0.281246 8.98832 0.928575 8.57424L18.6696 2.59378C19.4911 2.32424 20.2098 2.75393 19.9419 3.85158Z"
                                fill="white" />
                        </svg>
                    </a>
                </div>
            </div>
        </div>
        <div class="footer-copy">
            © Муниципальное автономное общеобразовательное учреждение "Лицей № 38"
        </div>
    </footer>
    <script src="{% static 'js/global/base.js' %}"></script>
</body>
</html>
